var gulp=require("gulp"),
livereload=require("gulp-livereload"),
webserver=require("gulp-webserver"),
sass=require("gulp-ruby-sass"),
uglify=require("gulp-uglify")
//刷新页面
gulp.task("shuaxin",function(){
	return gulp.src("dest").pipe(webserver({
		livereload:true,
		open:true
	}))
})
//移动文件
gulp.task("move",function(){
	return gulp.src("src/**/*.{html,css,js,jpg,png,gif}")
	.pipe(gulp.dest("dest"))
})
//编译sass
gulp.task("sass",function(){
	return sass("src/scss/*.scss",{style:"compressed"})
	.on("error",function(err){
		console.log(err)
	})
	.pipe(gulp.dest("dest/css"))
})
//压缩js代码
gulp.task("jsmin",function(){
	return gulp.src("src/js/*.js")
	.pipe(uglify())
	.pipe(gulp.dest("dest/js"))
})
//监听事件
gulp.task("watch",function(){
	gulp.watch("src/**/*.{html,css,js,jpg,png,gif}",["move"])
	gulp.watch("src/**/*.scss",["sass"])
})
//一起执行
gulp.task("default",["move","sass","jsmin","watch","shuaxin"])
